#
#SPDB_Informix_DBSPI_1017
# critical <0.15  正常 >0.25  major <0.25
# "0" : 
# "1" : 正常
su - $sys_user -c "$Souce_File dbaccess sysmaster" <<! >/dev/null 2>&1
unload to /tmp/dbspace.tmp
SELECT A.dbsnum as No, trim(B.name) as name, 
 CASE  WHEN (bitval(B.flags,'0x10')>0 AND bitval(B.flags,'0x2')>0) 
  THEN 'MirroredBlobspace'   
  WHEN bitval(B.flags,'0x10')>0  THEN 'Blobspace'   
  WHEN bitval(B.flags,'0x2000')>0 AND bitval(B.flags,'0x8000')>0  
  THEN 'TempSbspace'   
  WHEN bitval(B.flags,'0x2000')>0 THEN 'TempDbspace'   
  WHEN (bitval(B.flags,'0x8000')>0 AND bitval(B.flags,'0x2')>0)  
  THEN 'MirroredSbspace'   
  WHEN bitval(B.flags,'0x8000')>0  THEN 'SmartBlobspace'  
  WHEN bitval(B.flags,'0x2')>0    THEN 'MirroredDbspace'  
  ELSE   'Dbspace'   
 END  as dbstype,        
 CASE  WHEN bitval(B.flags,'0x4')>0   THEN 'Disabled' 
  WHEN bitand(B.flags,3584)>0  THEN 'Recovering'   
  ELSE    'Operational'    
 END  as dbsstatus, 
  TRUNC(100-sum(decode(mdsize,-1,nfree,udfree))*100/sum(chksize),2) as used
FROM syschktab A, sysdbstab B  
 WHERE A.dbsnum = B.dbsnum   
 and trim(B.name) not in ('physdbs','phydbs','logsdbs','logdbs')
GROUP BY A.dbsnum,name, 3, 4   
 ORDER BY A.dbsnum;
!

#awk -F "|" '{if ($5>=$Threshold) print "The usage of dbspace " $2 " is more then threshold. Current usage is " $5}' /tmp/dbspace.tmp
SPDB_Informix_DBSPI_1017=$(awk -F "|" '{print $5}' /tmp/dbspace.tmp)
rm /tmp/dbspace.tmp

echo SPDB_Informix_DBSPI---"$SPDB_Informix_DBSPI_1017" 